+function($){
	$.fn.seltree  = function(option){
		return this.each(function(){
			console.info(this);
			var self = this;
			this.options = {
				resultBox: ".seltree-resultbox",
				dropdownMenu: ".seltree-dropdown-menu",
				leafItem: ".seltree-leafItem"
			};
			$.extend(true, this.options, option);
			this.$resultBox = $(this.options.resultBox);
			this.$dropdownMenu = $(this.options.dropdownMenu);
			this.$leafItem = $(this.options.leafItem);
			this.$trunkItem = $(this.options.dropdownMenu + " li:not(" + this.options.leafItem + ") > span:first-of-type");
			console.info(this.$trunkItem);
			this.$resultBox.click(function(){
				if(self.$dropdownMenu.css("display") === "none"){
					self.$dropdownMenu.css("display","inline-block");
				}else{
					self.$dropdownMenu.css("display","none");
				}
			});
			this.$leafItem.click(function(){
				var filterText = $(this).find("span").html().trim();
				self.$resultBox.html(filterText);
				self.$dropdownMenu.css("display", "none");
				$(this).parents(self.options.dropdownMenu).find(self.options.leafItem).removeClass("active");
				$(this).addClass("active")
			});
			this.$trunkItem.click(function(){
				$(this).parent().toggleClass("open").siblings().removeClass("open");
			})
		})
	};
}(jQuery)
